package cn.iocoder.yudao.module.handguard.dal.mysql.productaccessrecord;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.productaccessrecord.ProductAccessRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.admin.productaccessrecord.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 产品准入-产品备注/产品特点记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ProductAccessRecordMapper extends BaseMapperX<ProductAccessRecordDO> {

    default PageResult<ProductAccessRecordDO> selectPage(ProductAccessRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductAccessRecordDO>()
                .eqIfPresent(ProductAccessRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ProductAccessRecordDO::getOrderNo, reqVO.getOrderNo())
                .eqIfPresent(ProductAccessRecordDO::getAccessId, reqVO.getAccessId())
                .eqIfPresent(ProductAccessRecordDO::getProcedures, reqVO.getProcedure())
                .eqIfPresent(ProductAccessRecordDO::getModeOfRepayment, reqVO.getModeOfRepayment())
                .eqIfPresent(ProductAccessRecordDO::getTimeRate, reqVO.getTimeRate())
                .eqIfPresent(ProductAccessRecordDO::getDeadline, reqVO.getDeadline())
                .eqIfPresent(ProductAccessRecordDO::getQuotaFormula, reqVO.getQuotaFormula())
                .eqIfPresent(ProductAccessRecordDO::getMonthlyInfo, reqVO.getMonthlyInfo())
                .betweenIfPresent(ProductAccessRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductAccessRecordDO::getId));
    }

    default List<ProductAccessRecordDO> selectList(ProductAccessRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ProductAccessRecordDO>()
                .eqIfPresent(ProductAccessRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ProductAccessRecordDO::getOrderNo, reqVO.getOrderNo())
                .eqIfPresent(ProductAccessRecordDO::getAccessId, reqVO.getAccessId())
                .eqIfPresent(ProductAccessRecordDO::getProcedures, reqVO.getProcedure())
                .eqIfPresent(ProductAccessRecordDO::getModeOfRepayment, reqVO.getModeOfRepayment())
                .eqIfPresent(ProductAccessRecordDO::getTimeRate, reqVO.getTimeRate())
                .eqIfPresent(ProductAccessRecordDO::getDeadline, reqVO.getDeadline())
                .eqIfPresent(ProductAccessRecordDO::getQuotaFormula, reqVO.getQuotaFormula())
                .eqIfPresent(ProductAccessRecordDO::getMonthlyInfo, reqVO.getMonthlyInfo())
                .betweenIfPresent(ProductAccessRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductAccessRecordDO::getId));
    }

    void deleteRecordById(@Param("orderNo") Long orderId);

}
